package com.ala4.oxcafe.controller;

import com.ala4.oxcafe.boot.page.PageDomain;
import com.ala4.oxcafe.boot.page.PageResult;
import com.ala4.oxcafe.domain.R;
import com.ala4.oxcafe.entity.FilmProduct;
import com.ala4.oxcafe.service.FilmProductService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author PING
 * @version 1.0.0
 * @date 2025/8/14 13:13
 */
@RestController
@RequestMapping("/film-product")
@AllArgsConstructor
@Tag(name = "车膜产品管理", description = "用于管理车膜产品信息")
public class FilmProductController {

    private final FilmProductService filmProductService;

    @Operation(summary = "分页查询车膜产品")
    @GetMapping("/page")
    public R<PageResult<FilmProduct>> page(PageDomain pageDomain, FilmProduct filmProduct) {
        return R.ok(PageResult.iPage(filmProductService.filmProductPage(pageDomain, filmProduct)));
    }

    @Operation(summary = "创建车膜产品")
    @PostMapping("/create")
    public R<FilmProduct> create(@RequestBody @Validated(FilmProduct.Create.class) FilmProduct filmProduct) {
        return R.ok(filmProductService.createFilmProduct(filmProduct));
    }

    @Operation(summary = "更新车膜产品")
    @PutMapping("/update")
    public R<FilmProduct> update(@RequestBody @Validated(FilmProduct.Update.class) FilmProduct filmProduct) {
        return R.ok(filmProductService.updateFilmProduct(filmProduct));
    }

    @Operation(summary = "删除车膜产品")
    @DeleteMapping("/delete/{productId}")
    public R<?> delete(@PathVariable Long productId) {
        filmProductService.deleteFilmProduct(productId);
        return R.ok();
    }

    @Operation(summary = "车膜产品详情")
    @GetMapping("/{productId}")
    public R<FilmProduct> info(@PathVariable Long productId) {
        return R.ok(filmProductService.filmProductInfo(productId));
    }

}
